package com.yq.testmodule.second_floor;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager2;
import androidx.recyclerview.widget.RecyclerView;

import com.yq.testmodule.R;
import com.yq.testmodule.adapter.SimpleAdapter;

import java.util.ArrayList;
import java.util.List;

public class TestFragment extends Fragment {
    RecyclerView mRv;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_test, container, false);
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        mRv = view.findViewById(R.id.rv);
        mRv.setLayoutManager(new LinearLayoutManager2(getContext()));
        List<String> datas = new ArrayList<>();
        for (int i = 0; i < 80; i++) {
            datas.add("i" + i);
        }
        mRv.setAdapter(new SimpleAdapter(datas));


        SecondFloorActivity activity = (SecondFloorActivity) getActivity();
        activity.secondFloorView.addScrollerListener(dy -> {
            mRv.setTranslationY(dy);
//            Log.e("YYYY", "子页面移动的距离 ： "+dy);
        });

    }
}
